/**
 * 
 */
package fr.ece.ing4.si.mc.main;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import fr.ece.ing4.si.mc.gui.*;

/**
 * @author Cesar Berezowski, Gaspard Peyrot
 *
 */
public class Main {
	
	/**
	 * HashMap to stock the data sets read from the file
	 */
	private static Map<Integer, double[]> values;
	/**
	 * Reader to read from the file
	 */
	private static BufferedReader reader;
	
	/**
	 * @param args No arguments
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		
		readDataFromFile();
		MainWindow w = new MainWindow(values);
		w.setVisible(true);
	}
	
	/**
	 * Reads data sets from values.txt file and fills the HashMap
	 * @throws IOException
	 */
	public static void readDataFromFile() throws IOException{
		
		reader = new BufferedReader(new FileReader("values.txt"));
		values = new HashMap<Integer, double[]>();
		
		String stockInfo = null;
		
		reader.readLine();
		
		
		while((stockInfo = reader.readLine()) != null) {
			
			final String[] line = stockInfo.split(",");
			final double[] lineData = { Double.valueOf(line[1]), 
					Double.valueOf(line[2]), Double.valueOf(line[3]), Double.valueOf(line[4]), 
					Double.valueOf(line[5]), Double.valueOf(line[6]) };
			final Integer key = Integer.valueOf(line[0]);

			values.put(key, lineData); 
		}
	}

}
